﻿<%@ Page Title="Title" Language="C#" Inherits="System.Web.Mvc.ViewPage<List<GradeBook.Models.Task>>"
    MasterPageFile="~/Views/Shared/Site.Master" %>

<%@ Import Namespace="GradeBook.Models" %>
<%@ Import Namespace="GradeBook.Security" %>
<asp:Content runat="server" ID="Title" ContentPlaceHolderID="TitleContent">
    Мои задания
</asp:Content>
<asp:Content runat="server" ID="Main" ContentPlaceHolderID="MainContent">
    <img class="tasklogo" src="../../Content/logo.gif" alt="" />
    <table>
        <thead>
            <tr>
                <th>
                    №
                </th>
                <th>
                    Описание
                </th>
                <th>
                    Статус
                </th>
                <th>
                    Действия
                </th>
            </tr>
        </thead>
        <tbody>
            <% 
                foreach (Task task in Model)
                { %>
            <tr>
                <td>
                    <%= Html.Encode(task.Id)%>
                </td>
                <td>
                    <%= Html.Encode(task.Description)%>
                </td>
                <td>
                    <b>
                        <%
                            RelTaskUser relTaskUser = null;
                            using (GradeBookEntities db = new GradeBookEntities())
                            {
                                int userId = MemShPrvd.CurrUser().Id;
                                relTaskUser = db.RelTaskUser.FirstOrDefault(m => m.TaskId == task.Id && m.UserId == userId);
                            }%>
                        <% if (relTaskUser != null)
                           { %>
                        <% if (relTaskUser.TaskMark == 0)
                           { %>
                        <%= string.IsNullOrEmpty(relTaskUser.Conclusion) ? 
                            "<p style=\"color: red;\">Не выполнено</p>" 
                                                    : "<p style=\"color: blue;\">В процессе оценивания</p>" %>
                        <% }
                           else
                           { 
                        %>
                        <p style="color: green;">
                            Выполнено (оценка:
                            <%= Html.Encode(relTaskUser.TaskMark)%>
                            )</p>
                        <% } %>
                        <% } %>
                    </b>
                </td>
                <td>
                    <%= Html.ActionLink("Просмотр", "Task", "Student", new { taskId = task.Id }, null)%>
                </td>
            </tr>
            <% } %>
        </tbody>
    </table>
</asp:Content>
